package tech.aistar.day03;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * 本类用来演示: 日历
 *
 * @author: success
 * @date: 2022/7/20 9:47 上午
 */
public class CalendarDemo {
    public static void main(String[] args) {
        //Calendar cal = new GregorianCalendar();

        Calendar cal = Calendar.getInstance();

        System.out.println(cal);

        //获取年份
        //1. 字面量 - 可读性比较差
        //int year = cal.get(1);
        int year = cal.get(Calendar.YEAR);

        System.out.println(year);

        //month-[0,11]
        System.out.println(cal.get(Calendar.MONTH)+1);

        System.out.println(cal.get(Calendar.DAY_OF_MONTH));//20


        //统一进行赋值
        //cal.set(2022,6,24);

        // 默认的是周日是数字1
        //System.out.println(cal.get(Calendar.DAY_OF_WEEK)-1);

        //Date getTime();//Calendar=>Date
        Date now = cal.getTime();
        System.out.println(now);

        Date dt = new Date(212121212121L);
        cal.setTime(dt);

        System.out.println(cal);

    }
}
